package com.ssm.controller;

import com.ssm.entity.ElcRoleInfotype;
import com.ssm.service.ElcRoleInfotypeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * (ElcRoleInfotype)表控制层
 *
 * @author makejava
 * @since 2021-06-01 10:40:51
 */
@RestController
@RequestMapping("elcRoleInfotype")
public class ElcRoleInfotypeController {
    /**
     * 服务对象
     */
    @Resource
    private ElcRoleInfotypeService elcRoleInfotypeService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public ElcRoleInfotype selectOne(Integer id) {
        return this.elcRoleInfotypeService.queryById(id);
    }

    @GetMapping("query/{id}")
    public List<Integer> queryById(@PathVariable Integer id) {
        List<ElcRoleInfotype> elcRoleInfotypes = elcRoleInfotypeService.queryByUserId(id);
        List<Integer> integers = new ArrayList<>();
        for (ElcRoleInfotype elcRoleInfotype:elcRoleInfotypes){
            integers.add(elcRoleInfotype.getInfoTypeId());
        }
        return integers;
    }

}
